include "map_builder.lua"
include "trajectory_builder.lua"

TRAJECTORY_BUILDER.pure_localization_trimmer = {
    max_submaps_to_keep = 2,
}

options = {
  map_builder = MAP_BUILDER,
  trajectory_builder = TRAJECTORY_BUILDER,
  map_frame = "map", 
  tracking_frame = "base_link",
  published_frame = "base_link", 
  odom_frame = "odom", 
  provide_odom_frame = true,
  publish_frame_projected_to_2d = false,
  use_odometry = true,--false
  use_nav_sat = false, 
  use_landmarks = false,
  use_qr_code = true,
  qr_code_translation_weight = 1e6,
  qr_code_rotation_weight = 1e6,
  num_laser_scans = 1, 
  num_multi_echo_laser_scans = 0,
  num_subdivisions_per_laser_scan = 1,
  num_point_clouds = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-2,
  trajectory_publish_period_sec = 5e-2,
  rangefinder_sampling_ratio = 1.,
  odometry_sampling_ratio = 1.,
  fixed_frame_pose_sampling_ratio = 1.,
  imu_sampling_ratio = 1.,
  landmarks_sampling_ratio = 1.,
  qr_code_sampling_ratio = 1.0,--0.2
  cache_data_time_duration_sec = 2000,--1200
  sensor_data_log_path = "Slam_log/sensor_data",
  initial_pose_time_interval_sec = -1,
}

TRAJECTORY_BUILDER_2D.submaps.num_range_data = 40
TRAJECTORY_BUILDER_2D.use_odom_in_front = false --false
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.min_range = 0.5
TRAJECTORY_BUILDER_2D.max_range = 80.0

TRAJECTORY_BUILDER_2D.ceres_scan_matcher.occupied_space_weight = 1
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.translation_weight = 1
TRAJECTORY_BUILDER_2D.ceres_scan_matcher.rotation_weight = 1

TRAJECTORY_BUILDER_2D.motion_filter.max_time_seconds = 1 ---5
TRAJECTORY_BUILDER_2D.motion_filter.max_angle_radians = math.rad(3) --5
TRAJECTORY_BUILDER_2D.motion_filter.max_distance_meters = 0.1  --0.2

TRAJECTORY_BUILDER_2D.use_reflector = false
POSE_GRAPH.use_reflector = false

POSE_GRAPH.constraint_builder.sampling_ratio = 0.1
POSE_GRAPH.constraint_builder.max_constraint_distance = 8
POSE_GRAPH.constraint_builder.min_score = 0.55

POSE_GRAPH.optimize_every_n_nodes = 2 --1
POSE_GRAPH.global_sampling_ratio = 0.001
POSE_GRAPH.slam_evaluator.distance_traveled_threshold = 10
POSE_GRAPH.slam_evaluator.distance_traveled_threshold_initial = 1
POSE_GRAPH.constraint_builder.localization_mode = true

POSE_GRAPH.constraint_builder.fast_correlative_scan_matcher.use_dynamic_parameters_after_n_nodes=5
POSE_GRAPH.constraint_builder.fast_correlative_scan_matcher.linear_search_window = 5
POSE_GRAPH.constraint_builder.fast_correlative_scan_matcher.angular_search_window = math.rad(30.)
POSE_GRAPH.constraint_builder.loop_closure_translation_weight = 1e6
POSE_GRAPH.constraint_builder.loop_closure_rotation_weight = 1e6

return options
